local zhuhu = fk.CreateSkill {
  name = "lvshi__zhuhu",
  tags = {"Turn"}
}

Fk:loadTranslationTable{
  ["lvshi__zhuhu"] = "踏虏",
  ["@lvshi__zhuhu-turn"] = "踏虏",
  [":lvshi__zhuhu"] = "回合技，当你使用【杀】结算后，你可视为对一名目标角色使用【调虎离山】并摸一张牌，然后你于此回合使用【杀】次数上限和造成的伤害+1，若此【杀】未造成伤害，重置此技能。",
  ["#lvshi__zhuhu-target"] = "踏虏：你可视为对一名目标角色使用【调虎离山】",
  ["$lvshi__zhuhu1"] = "驰骋疆场，张弓搭箭，以射敌酋！",
  ["$lvshi__zhuhu2"] = "纵横草原，拔剑擎枪，直取寇首！",
}

zhuhu:addEffect(fk.CardUseFinished, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(zhuhu.name) and data.card.trueName == "slash"
    and player:usedSkillTimes(zhuhu.name) == 0
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local card = Fk:cloneCard("lvshi__lure_tiger")
    local to = room:askToChoosePlayers(player, {
      targets = table.filter(data.tos, function (p) return player:canUseTo(card, p) end),
      min_num = 1,
      max_num = 1,
      skill_name = zhuhu.name,
      cancelable = true,
      prompt = "#lvshi__zhuhu-target",
    })
    if #to > 0 then
      event:setCostData(self, {tos = to})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
      local to = event:getCostData(self).tos[1]
      player:drawCards(1, zhuhu.name)
      player.room:useVirtualCard("lvshi__lure_tiger", nil, player, to, zhuhu.name, true)
      if not player.dead then
        player.room:addPlayerMark(player, "@lvshi__zhuhu-turn")
        if not data.damageDealt then
          player:setSkillUseHistory(self.name, 0, Player.HistoryTurn)
        end
      end
    end,
})

zhuhu:addEffect(fk.DamageCaused, {
  can_refresh = function(self, event, target, player, data)
    return target == player and player:getMark("@lvshi__zhuhu-turn") > 0 and data.card and data.card.trueName == "slash"
  end,
  on_refresh = function(self, event, target, player, data)
    data:changeDamage(player:getMark("@lvshi__zhuhu-turn"))
  end,
})

zhuhu:addEffect("targetmod", {
  residue_func = function(self, player, skill, scope, card)
    if skill.trueName == "slash_skill" and card and player:getMark("@lvshi__zhuhu-turn") > 0 and scope == Player.HistoryPhase then
      return player:getMark("@lvshi__zhuhu-turn")
    end
  end,
  distance_limit_func =  function(self, player, skill)
    if player:hasSkill(zhuhu.name) and skill.trueName == "slash_skill" and player:getMark("@lvshi__zhuhu-turn") > 0 then
      return 999
    end
  end,
})


return zhuhu
